<!-- 智慧工厂 -->
<template>
  <div class="factory">
    <header :style="'background: url(' + back + ') no-repeat 50% 50%;'">
      <span>{{ i18n.factory.journalism }}</span>
    </header>
    <div class="list" v-for="(val,ins) in list" :key="val.title">
      <span><img :src="val.img" /></span>
      <main>
        <span>{{ ins+1 }}</span>
        <p>
          <b>{{val.title}}</b>
          {{ val.content }}
        </p>
      </main>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import bus from "@/config/emit";

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      back: '',
      list:[]
    };
  },
  //计算属性 类似于data概念
  computed: {
    i18n() {
      return this.$t("message");
    },
  },
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    getFactory() {
      this.$getRequest("/index/getFactory").then((res) => {
          this.back = res.data.factory_back;
          this.list=res.data.module
      });
    },
  },
  beforeCreate() {}, //生命周期 - 创建之前
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.getFactory();
    bus.$on("lang", () => {
      if (this.$route.name == "/factory") {
        this.getFactory();
      }
    });
  },
  beforeMount() {}, //生命周期 - 挂载之前
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {
    this.getFactory();
  }, //如果页面有keep-alive缓存功能，激活
  deactivated() {}, //如果页面有keep-alive缓存功能，非激活
};
</script>
<style lang="less">
.factory {
  & > .list:nth-child(2n) {
    flex-direction: row-reverse;
  }

  & > .list {
    width: 17.5rem;
    height: 6.375rem;
    display: flex;
    align-items: center;
    margin: 0.5rem auto;

    & > main {
      width: 50%;
      display: flex;
      align-items: flex-start;
      padding: 0 0 0 0.475rem;
      box-sizing: border-box;

      & > p {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-bottom: 0.5rem;
        font-size: 0.25rem;

        & > b {
          line-height: 0.75rem;
          font-size: 0.375rem;
        }
      }

      & > span {
        font-size: 0.625rem;
        font-weight: bold;
        line-height: 0.75rem;
        width: 0.625rem;
        text-align: center;
        background: url("../assets/factory/2.png") no-repeat 0 70%;
        background-size: 100%;
      }
    }

    & > span {
      width: 50%;
      height: 6.375rem;
      position: relative;
      overflow: hidden;

      & > img {
        min-width: 100%;
        min-height: 6.375rem;
        height: 6.375rem;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }

  & > header {
    width: 100%;
    height: 7.5rem;
    background-size: 100% 100% !important;
    color: #fff;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
  }
}

@media screen and (max-width: 768px) {
  .factory {
    & > .list {
      width: 33.5rem;
      min-height: 15rem;
      margin: 2rem auto;
      position: relative;
      overflow: hidden;

      & > main {
        width: 100%;
        min-height: 15rem;
        padding: 1rem;
        background-color: #ffffff80;

        & > p {
          margin-bottom: 1rem;
          font-size: 1rem;

          & > b {
            line-height: 3rem;
            font-size: 1.3rem;
          }
        }

        & > span {
          font-size: 1.1rem;
          line-height: 3rem;
          width: 2rem;
        }
      }

      & > span {
        min-width: 100%;
        min-height: 20rem;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: -999;

        & > img {
          min-height: 20rem;
          height: 20rem;
          filter: blur(5px);
        }
      }
    }

    & > header {
      height: 20rem;
      background-size: auto 100% !important;
      font-size: 1.5rem;
    }
  }
}
</style>